﻿package com.valeosys 
{
import com.valeosys.TopLevel;
import com.valeosys.navigation.accordion;
import com.valeosys.utils.*;
import caurina.transitions.Tweener;
import flash.display.MovieClip;
import fl.controls.ScrollBarDirection;
import fl.data.DataProvider;

public class AccordionMenu extends TopLevel {
		var accord:accordion;
		var shPanel:MovieClip;
		var bgPanel:MovieClip;
		var txPanel:MovieClip;
		var upPanel:MovieClip;
		var accWidth;
		var accHeight;
		var accPadding;
		var numPanels:Number = 4;
		var navSize:Number = 80;
		public function AccordionMenu(w:Number, h:Number, p:Number, bgDp:DataProvider, shDp:DataProvider) {
			accWidth = w;
			accHeight = h;
			accPadding = p;
			accord = new accordion(w, h, numPanels, navSize);
			addChild(accord);
			
			//add horizontal panels
			//accord.addPanel(new navpanel, new contents);
			//accord.addPanel(new navpanel, new contents);
			//accord.addPanel(new navpanel, new contents);
			//accord.addPanel(new navpanel, new contents);
			//accord.openPanel(1);
			
			//add vertical panels
			shPanel = new menuShapePanel;
			bgPanel = new menuImagePanel;
			txPanel = new menuTextPanel;
			upPanel = new menuUploadPanel;
			var ratio:Number = (w - p) / txPanel.width;
			txPanel.width = w - p;
			txPanel.height = ratio * txPanel.height;
			upPanel.width = w - p;
			upPanel.height = ratio * upPanel.height;
			updateDataProvider(bgDp, shDp);
			accord.addVerticalPanel(new navpanelBackground, bgPanel);
			accord.addVerticalPanel(new navpanelShape, shPanel);
			accord.addVerticalPanel(new navpanelText, txPanel);
			accord.addVerticalPanel(new navpanelUpload, upPanel);
			accord.openVerticalPanel(1);
		}
		public function updateDataProvider(bgDp:DataProvider, shDp:DataProvider) {
			
			shPanel.ShapeTileList.direction = ScrollBarDirection.VERTICAL;
			shPanel.ShapeTileList.rowHeight = (accWidth - accPadding) / 2;
			shPanel.ShapeTileList.columnWidth = (accWidth - accPadding) / 2;
			shPanel.ShapeTileList.width = accWidth - accPadding;
			shPanel.ShapeTileList.height = accHeight - (numPanels * navSize) - (accPadding * 2);
			shPanel.ShapeTileList.dataProvider = shDp;
			shPanel.ShapeTileList.columnCount = 2;
			//shPanel.ShapeTileList.MenuShapeBaseTip.visible = false;
			//removeChild(shPanel.ShapeTileList.MenuShapeBaseTip);
			
			bgPanel.BgTileList.direction = ScrollBarDirection.VERTICAL;
    		bgPanel.BgTileList.rowHeight = (accWidth - accPadding) / 2;
    		bgPanel.BgTileList.columnWidth = (accWidth - accPadding) / 2;
			bgPanel.BgTileList.width = accWidth - accPadding;
    		bgPanel.BgTileList.height = accHeight - (numPanels * navSize) - (accPadding * 2);
    		bgPanel.BgTileList.dataProvider = bgDp;
			bgPanel.BgTileList.columnCount = 2;
    		//bgPanel.BgTileList.MenuImageBaseTip.visible = false;
			//removeChild(bgPanel.BgTileList.MenuImageBaseTip);
		}
	}
}